
import react, {Component} from 'react';
import { Popover, Button, Icon, Form, Col, Row, Input } from 'antd';
const FormItem = Form.Item;

class InputPop extends Component {

    handleSubmit = e => {
        e.preventDefault();
        const { form } = this.props;
        if (form) {
            form.validateFields((err, values) => {
                if (err) return;
                console.log(values);
                //submit 提交
            })
        }
    }
    render() {
        const {form} = this.props;
        return (
            <Popover content={(
                <FormItem>
                    <Row gutter={8}>
                        <Col span={18}>
                            {form.getFieldDecorator('category', {
                                rules: [
                                    {
                                        require: true,
                                        message: '请输入至少五个字符得规则描述！',
                                        min: 5
                                    }
                                ]
                            })(<Input placeholder="请输入要添加的分类名称" />)}
                        </Col>
                        <Col span={6}>
                            <Button
                            type="primary"
                            onClick={this.handleSubmit}
                            >
                                确定
                            </Button>
                        </Col>
                    </Row>
                </FormItem>
            )} title="添加分类" trigger="click" placement="right">
                <Button  type="primary">
                    添加分类
                </Button>
            </Popover>
        )
    }
}

export default Form.create()(InputPop);